<template>
	<view class="index">
		<!-- 顶部切换 -->
		<view class="header">
			<view class="left">
				<image src="/static/images/home/门店.png" mode="aspectFit" class="icon"></image>
				<text class="branch-name">中山路分馆</text>
			</view>
			<view class="right">
				<image src="/static/images/home/iconPark-refresh@1x.png" mode="aspectFit" class="icon"></image>
			</view>
		</view>
		
		<!-- 轮播图 -->
		<swiper class="banner" :indicator-dots="true" :autoplay="true" :interval="3000" :duration="500">
			<swiper-item v-for="(image, index) in bannerImages" :key="index">
				<image :src="image" mode="aspectFill" class="banner-image"></image>
			</swiper-item>
		</swiper>
		
		<!-- 今日运营快报 -->
		<view class="section">
			<view class="section-header">
				<text class="title">今日运营快报</text>
				<view class="more">
					<image src="/static/images/home/ze-apps-o@1x.png" mode="aspectFit" class="icon-small"></image>
					<text>更多</text>

				</view>
			</view>
			<view class="grid-wrap">
				<view class="grid">
					<view class="grid-item" v-for="(item, index) in todayData" :key="index">
						<view class="grid-item-content">
							<text class="number">{{item.number}}</text>
							<text class="label">{{item.label}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
		
		<!-- 本月运营情况 -->
		<view class="section">
			<view class="section-header">
				<text class="title">本月运营情况</text>
				<view class="more">
					<image src="/static/images/home/ze-apps-o@1x.png" mode="aspectFit" class="icon-small"></image>
					<text>更多</text>

				</view>
			</view>
			<view class="grid-wrap">
				<view class="grid">
					<view class="grid-item" v-for="(item, index) in monthData" :key="index">
						<view class="grid-item-content">
							<text class="number">{{item.number}}</text>
							<text class="label">{{item.label}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>

		<!-- 今日预约 -->
		<view class="section">
			<view class="section-header">
				<text class="title">今日预约</text>
				<view class="more">
					<image src="/static/images/home/ze-apps-o@1x.png" mode="aspectFit" class="icon-small"></image>
					<text>更多</text>

				</view>
			</view>
			<view class="appointment-list">
				<view class="appointment-item" v-for="(item, index) in appointmentList" :key="index">
					<view class="main-content">
						<view class="left">
							<image :src="item.avatar" mode="aspectFill"></image>
						</view>
						<view class="center">
							<view class="course-name">
								<text>脊柱灵动</text>
								<view class="tag">预约</view>
							</view>
							<view class="time">时间：{{item.time}}</view>
							<view class="teacher">老师：{{item.teacher}}</view>
						</view>
						<view class="right">
							<image src="/static/images/home/预约图标.png" mode="aspectFit"></image>
						</view>
					</view>
					<view class="booking-info">
						<text>预约：{{item.booked}}</text>
						<text>剩余：{{item.remaining}}</text>
						<text>{{item.progress}}%</text>
					</view>
					<view class="progress-bar">
						<view class="progress" :style="{width: item.progress + '%'}"></view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
import { ref } from 'vue'

const bannerImages = ref([
	'/static/images/home/轮播图 1@1x.png',
	'/static/images/home/轮播图 1@1x.png'
])

const todayData = ref([
	{ number: '100人', label: '销售数' },
	{ number: '10,000元', label: '销售额' },
	{ number: '100人', label: '团课/班课预约人数' },
	{ number: '100人', label: '私教预约人数' },
	{ number: '100人', label: '体验人数' },
	{ number: '100人', label: '新增会员数' },
	{ number: '100人', label: '新增游客数' }
])

const monthData = ref([
	{ number: '100人', label: '销售数' },
	{ number: '10,000元', label: '销售额' },
	{ number: '100节', label: '团课数量' },
	{ number: '100节', label: '班课数量' },
	{ number: '100节', label: '私教数量' },
	{ number: '100人', label: '体验人数' }
])

const appointmentList = ref([
	{	
		avatar: '/static/images/home/图片 1@1x.png',
		time: '09:00-10:00',
		teacher: '李玉',
		booked: 15,
		remaining: 15,
		progress: 50
	},
	{
		avatar: '/static/images/home/图片 1@1x.png',
		time: '09:30-10:30',
		teacher: '李玉',
		booked: 15,
		remaining: 30,
		progress: 30
	}
])
</script>

<style lang="scss" scoped>
.index {
	padding: 20rpx;
	background-color: #f5f5f5;
	min-height: 100vh;
	
	.header {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 20rpx;
		background-color: #FFD700;
		border-radius: 16rpx;
		margin-bottom: 20rpx;
		
		.left {
			display: flex;
			align-items: center;
			
			.branch-name {
				font-size: 32rpx;
				font-weight: bold;
				margin-left: 10rpx;
			}
		}
		
		.icon {
			width: 40rpx;
			height: 40rpx;
		}
	}
	
	.banner {
		height: 300rpx;
		border-radius: 16rpx;
		overflow: hidden;
		margin-bottom: 20rpx;
		
		.banner-image {
			width: 100%;
			height: 100%;
		}
	}
	
	.section {
		padding: 20rpx;
		margin-bottom: 20rpx;
		
		.section-header {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 20rpx;
			
			.title {
				font-size: 32rpx;
				font-weight: bold;
				color: #333;
			}
			
			.more {
				display: flex;
				align-items: center;
				color: #999;
				font-size: 28rpx;
				
				.icon-small {
					width: 28rpx;
					height: 28rpx;
					margin-left: 4rpx;
				}
			}
		}
		
		.grid-wrap {
			padding: 20rpx;
			
			.grid {
				display: flex;
				flex-wrap: wrap;
				margin: -10rpx;
				
				.grid-item {
					width: calc(33.33% - 20rpx);
					margin: 10rpx;
					
					.grid-item-content {
						background-color: #fff;
						border: 2rpx solid #FFD700;
						border-radius: 16rpx;
						padding: 20rpx;
						display: flex;
						flex-direction: column;
						align-items: center;
						
						.number {
							font-size: 32rpx;
							font-weight: bold;
							color: #333;
							margin-bottom: 10rpx;
						}
						
						.label {
							font-size: 24rpx;
							color: #999;
							text-align: center;
						}
					}
				}
			}
		}

		.appointment-list {
			.appointment-item {
				background-color: #fff;
				border-radius: 16rpx;
				padding: 20rpx;
				margin-bottom: 20rpx;
				display: flex;
				
				.main-content {
					display: flex;
					align-items: flex-start;
					margin-bottom: 20rpx;
					
					.left {
						width: 100rpx;
						height: 100rpx;
						margin-right: 20rpx;
						
						image {
							width: 100%;
							height: 100%;
							border-radius: 8rpx;
						}
					}
					
					.center {
						flex: 1;
						
						.course-name {
							display: flex;
							align-items: center;
							margin-bottom: 10rpx;
							
							text {
								font-size: 32rpx;
								font-weight: bold;
								margin-right: 16rpx;
							}
							
							.tag {
								background-color: #FFB800;
								color: #fff;
								font-size: 24rpx;
								padding: 2rpx 12rpx;
								border-radius: 6rpx;
							}
						}
						
						.time, .teacher {
							font-size: 28rpx;
							color: #666;
							line-height: 40rpx;
						}
					}
					
					.right {
						width: 40rpx;
						height: 40rpx;
						
						image {
							width: 100%;
							height: 100%;
						}
					}
				}
				
				.booking-info {
					display: flex;
					justify-content: flex-end;
					font-size: 24rpx;
					color: #666;
					margin-bottom: 10rpx;
					
					text {
						margin-left: 20rpx;
					}
				}
				
				.progress-bar {
					height: 8rpx;
					background-color: #eee;
					border-radius: 4rpx;
					overflow: hidden;
					
					.progress {
						height: 100%;
						background-color: #4CD964;
						border-radius: 4rpx;
					}
				}
			}
		}
	}
}

.booking-info {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	font-size: 28rpx;
	color: #666;
	margin: 16rpx 0;
	
	.divider {
		margin: 0 16rpx;
		color: #ddd;
	}
}

.progress-wrap {
	display: flex;
	align-items: center;
	
	.progress-bar {
		flex: 1;
		height: 8rpx;
		background-color: #f5f5f5;
		border-radius: 4rpx;
		margin-right: 16rpx;
		overflow: hidden;
		
		.progress {
			height: 100%;
			background-color: #4cd964;
			border-radius: 4rpx;
		}
	}
	
	.progress-text {
		font-size: 24rpx;
		color: #666;
	}
}
</style>
